home *** CD-ROM | disk | FTP | other *** search
- Path: lrz-muenchen.de!news
- From: watzka@stat.uni-muenchen.de (Kurt Watzka)
- Newsgroups: comp.lang.c
- Subject: Re: Calling a function by reference?!
- Date: 11 Mar 1996 15:39:19 GMT
- Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
- Distribution: world
- Message-ID: <4i1hf7$k3q@sparcserver.lrz-muenchen.de>
- References: <ga16wMlyZAQF088yn@ime.usp.br>
- NNTP-Posting-Host: sun2.lrz-muenchen.de
-
- rbrito@ime.usp.br (Rogerio Brito) writes:
-
- > How do I declare a function (say, foo) that receives two
- > strings and does modifications to both?
-
- > Is there a better way than:
- >
- > void foo(char **argument1, char **argument2);
-
- It depends on what kind of modifications your function will do
- to those stirngs. If the pointer whose address you pass to foo()
- will point to a different location in memory when your function
- returns, passing a pointer to a pointer is a good idea. If you
- want to change all uppercase 'A' character to 'Z', passing the
- pointer to the first character is enough, because you will not
- modify the _location_ that the pointer points to, only the
- _contents_ of the string that the pointer points to.
-
- > ?? (It seems to be a dirty way... :( )
-
- I'm afraid I don't understand that remark.
-
- Kurt
- --
- | Kurt Watzka Phone : +49-89-2180-6254
- | watzka@stat.uni-muenchen.de
- | ua302aa@sunmail.lrz-muenchen.de
-